package com.yueyang.sojourn.server.model.vo;

import com.yueyang.sojourn.server.model.enums.OrderEventTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 订单时间线
 * @author andy.yang
 * @summary
 * @Copyright (c) 2020, Yueyang Group All Rights Reserved.
 * @since 2020-03-24 10:45
 */
@Data
@ApiModel("订单事件")
public class SojournOrderTimeLineVo {
    /**
     * 此数据是否是当前节点
     */
    @ApiModelProperty(value = "是否是当前时间节点")
    private boolean isCurrent = false;

    /**
     * 方案
     */
    @ApiModelProperty(value = "文案")
    private String showDesc;

    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    private Long creator;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private Date createdTime;

    @Data
    public static class TimeLineNode{
        //订单类型
        OrderEventTypeEnum orderEventType;
        //描述
        String desc;

        public TimeLineNode(OrderEventTypeEnum orderEventType, String desc) {
            this.orderEventType = orderEventType;
            this.desc = desc;
        }
    }

    public static final List<TimeLineNode> dealedTimeLine = new ArrayList(){{
        add(new TimeLineNode(OrderEventTypeEnum.DEALED, "感谢选择阅阳，期待再次光临"));
        add(new TimeLineNode(OrderEventTypeEnum.DEALED, "您的出行信息已核实"));
        add(new TimeLineNode(OrderEventTypeEnum.TO_BE_TRIP, "您已完成支付"));
        add(new TimeLineNode(OrderEventTypeEnum.TO_BE_PAY, "订单已提交，等待支付"));
    }};

    public static final List<TimeLineNode> refundTimeLine = new ArrayList(){{
        add(new TimeLineNode(OrderEventTypeEnum.REFUND_START, "退款一般1-2个工作日原路返回，请注意查收"));
        add(new TimeLineNode(OrderEventTypeEnum.REFUND_START, "客服已为您操作退款"));
        add(new TimeLineNode(OrderEventTypeEnum.TO_BE_TRIP, "您已完成支付"));
        add(new TimeLineNode(OrderEventTypeEnum.TO_BE_PAY, "订单已提交，等待支付"));
    }};


    /**
     * 时间线策略
     * @param type 1-成交 2-退款
     */
    public static List<TimeLineNode> getTimeLineStrategy(Integer type){
        if (type == 1) {
            return dealedTimeLine;
        } else if (type == 2) {
            return refundTimeLine;
        }
        return new ArrayList<>();
    }
}
